package cn.jhc.transport.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by luyanfei on 16-2-28.
 */
public class SenseView extends View {

    private String label;
    private int currentValue;
    private float maxValue;

    public SenseView(Context context, AttributeSet attrs) {
        super(context, attrs);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRect(50.0f,50.0f,80.0f,50.0f+(currentValue/maxValue)*100,paint);
        canvas.drawText(this.label, 100.0f, 50.0f, paint);
        canvas.drawText(this.currentValue + "", 100.0f,80.0f,paint);
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public int getCurrentValue() {
        return currentValue;
    }

    public void setCurrentValue(int currentValue) {
        this.currentValue = currentValue;
        invalidate();
    }

    public float getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(float maxValue) {
        this.maxValue = maxValue;
    }
}
